// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   SET_CVImpl.java

package com.sunwayhorizo.health.hl7.datatypes.common;

import com.sunwayhorizo.health.hl7.datatypes.ANY;
import com.sunwayhorizo.health.hl7.datatypes.BL;
import com.sunwayhorizo.health.hl7.datatypes.CS;
import com.sunwayhorizo.health.hl7.datatypes.CV;
import com.sunwayhorizo.health.hl7.datatypes.SET_CV;
import com.sunwayhorizo.health.hl7.datatypes.TYPE;

import java.util.Set;


// Referenced classes of package oracle.apps.ctb.hl7.types.common:
//            SETCommonImpl, ANYImpl, BLImpl, CSImpl, 
//            TYPEImpl

public class SET_CVImpl extends SETCommonImpl
    implements SET_CV
{

    public static final String RCS_ID = "$Header: SET_CVImpl.java 115.14 2005/09/16 09:23:16 amchanda noship $";
    private static final SET_CV nullNI = new SET_CVImpl(CSImpl.valueOf("NI"));
    private static final SET_CV nullOTH = new SET_CVImpl(CSImpl.valueOf("OTH"));
    private static final SET_CV nullNINF = new SET_CVImpl(CSImpl.valueOf("NINF"));
    private static final SET_CV nullPINF = new SET_CVImpl(CSImpl.valueOf("PINF"));
    private static final SET_CV nullUNK = new SET_CVImpl(CSImpl.valueOf("UNK"));
    private static final SET_CV nullASKU = new SET_CVImpl(CSImpl.valueOf("ASKU"));
    private static final SET_CV nullNAV = new SET_CVImpl(CSImpl.valueOf("NAV"));
    private static final SET_CV nullMSK = new SET_CVImpl(CSImpl.valueOf("MSK"));
    private static final SET_CV nullNA = new SET_CVImpl(CSImpl.valueOf("NA"));
    private static final SET_CV nullNASK = new SET_CVImpl(CSImpl.valueOf("NASK"));

    public static SET_CV valueOf(CV acv[])
    {
        return new SET_CVImpl(acv);
    }

    public static SET_CV valueOf(CV cv)
    {
        return new SET_CVImpl(cv);
    }

    public static SET_CV valueOf(Set set)
    {
        return new SET_CVImpl(set);
    }

    public static SET_CV nullSET_CV()
    {
        return new SET_CVImpl(((CS) (null)));
    }

    protected SET_CVImpl(CV acv[])
    {
        if(acv == null)
            throw ANYImpl.newNullException("SET<CV>", "constructor", "elements");
        for(int i = 0; i < acv.length; i++)
            if(acv[i] != null && acv[i].isNull().isFalse())
                mSet.add(acv[i]);

    }

    protected SET_CVImpl(CV cv)
    {
        if(cv == null || cv.isNull().isTrue())
        {
            throw ANYImpl.newNullException("SET<CV>", "constructor", "element");
        } else
        {
            mSet.add(cv);
            return;
        }
    }

    public SET_CVImpl(Set set)
    {
        super(set);
    }

    public SET_CVImpl(CS cs)
    {
        super(cs);
    }

    public BL equal(ANY any)
    {
        if(!(any instanceof SET_CV))
            return BLImpl.FALSE;
        if(isNull().or(any.isNull()).isTrue())
        {
            return BLImpl.FALSE;
        } else
        {
            SET_CV set_cv = (SET_CV)any;
            return BLImpl.valueOf(equalsSet(set_cv.toSet()));
        }
    }

    public TYPE dataType()
    {
        return com.sunwayhorizo.health.hl7.datatypes.common.TYPEImpl.SET_CV;
    }

    protected boolean verifyItem(Object obj)
    {
        return (obj instanceof CV) && ((CV)obj).nonNull().isTrue();
    }

    public int hashCode()
    {
        return super.hashCode();
    }

    public static SET_CV nullSET_CV(CS cs)
    {
        String s = null;
        if(cs == null || cs.literal().stringValue() == null || cs.isNull().isTrue())
            s = "NI";
        else
            s = cs.literal().stringValue();
        if(s.equals("NI"))
            return nullNI;
        if(s.equals("OTH"))
            return nullOTH;
        if(s.equals("NINF"))
            return nullNINF;
        if(s.equals("PINF"))
            return nullPINF;
        if(s.equals("UNK"))
            return nullUNK;
        if(s.equals("ASKU"))
            return nullASKU;
        if(s.equals("NAV"))
            return nullNAV;
        if(s.equals("MSK"))
            return nullMSK;
        if(s.equals("NA"))
            return nullNA;
        if(s.equals("NASK"))
            return nullNASK;
        else
            return nullNI;
    }

}
